<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var food = prompt('请输入水果')

    switch(food) {
      case '葡萄':
        alert('7块')
        break
      case '西瓜':
        alert('1.5块')
        break
      default: 
        alert('没有此物')
    }
  </script>
</body>
</html>